using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class tbKhachHangBUS
    {
        public static void Insert(tbKhachHang kh)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Insert(kh);
        }
        public static void Update(tbKhachHang kh)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Update(kh);
        }
        public static void Delete(int iD)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Delete(iD);
        }
        public static tbKhachHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbKhachHangCollection GetAll()
        {
            int total = 0;
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get("where 1=1", 0, 0, tbKhachHangColumns.IdKhachHang.ToString(), "ASC", out total);
        }
        public static tbKhachHang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbKhachHangColumns.IdKhachHang.ToString(), Condition.EQUAL, iD);
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            tbKhachHangCollection khachhangCollection = khachhangDAL  .Get(cri.Criter ,0,0,
                                                        tbKhachHangColumns .IdKhachHang .ToString (),
                                                        OrderDirection .ASC .ToString (),out total );
            if (khachhangCollection.Count > 0)
                return khachhangCollection[0];
            return null;
        }
    }
}
